<%@page import="com.fishing.util.DateUtil"%>
<%@page import="java.text.SimpleDateFormat"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!doctype html>
<html>
<head>
<title>充值查询 -- </title>
<base href="<%=basePath%>" />
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="renderer" content="webkit">
<meta http-equiv="Cache-Control" content="no-siteapp" />
<link rel="apple-touch-icon-precomposed" href="i/app-icon72x72@2x.png">
<link rel="stylesheet" href="layui/css/layui.css" media="all" />
</head>
<%
	String today = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
%>
<body>
<br/>
			<div class="portlet-title">
				<div class="caption bold">
					&nbsp;&nbsp;<span style="font-size:18px;color:#f26522;">每日充值查询 </span>
				</div>
				<br/>
				<div class="layui-form-item">
					<form class="layui-form" id="queryForm" action=""  onsubmit='return false'>
						<div class="layui-form-item">
						    <div class="layui-input-inline">
							    <input type="text" name="UserID"  id="UserID" placeholder="请输入玩家ID" autocomplete="off" class="layui-input">
						    </div>
						    
						    <div class="layui-input-inline">
							    <input type="text" name="OrderID"  id="OrderID" placeholder="请输入订单ID" autocomplete="off" class="layui-input">
						    </div>
							<!-- 日期选择 -->
							<div class="layui-inline">
								<div class="layui-input-inline">
									<input type="text" class="layui-input" id="StartTime"
										placeholder="开始时间" lay-filter="startTime" name="startTime" autocomplete="off">
								</div>
							</div>
							<div class="layui-inline">
								<div class="layui-input-inline">
									<input type="text" class="layui-input" id="EndTime"
										placeholder="结束时间" lay-filter="endTime" name="endTime" autocomplete="off">
								</div>
							</div>
							
							            <div class="layui-inline">
							              <div class="layui-input-inline">
							              <select name="ContentType" id="ContentType" placeholder="全部订单" lay-filter="ContentType">
								              <option value="0">全部订单</option>
								              <option value="1">商城</option>
								              <option value="2">月卡</option>
								              <option value="3">首充礼包</option>
								              <option value="4">每日充值</option>
								              <option value="5">投资炮倍</option>
								              <option value="6">出海保险</option>
								              <option value="7">N天持续奖励</option>
								              <option value="8">炮倍解锁</option>
							              </select>
							              </div>
                                        </div>
                                        
                                        <div class="layui-inline">
							              <div class="layui-input-inline">
							              <select name="State" id="State" placeholder="全部" lay-filter="State">
								              <option value="0">全部订单</option>
								              <option value="1">未完成</option>
								              <option value="2">已完成</option>
							              </select>
							              </div>
                                        </div>

							<div class="layui-inline">
								<div class="layui-input-inline">
									<button class="layui-btn layui-btn-normal" data-type="reload"
										id="SelectOrder" onsubmit='return false'>搜索</button>
								</div>
							</div>
						</div>

					</form>
				</div>
			</div>
			<div class="layui-form">
					<table class="layui-table" lay-skin="nob" id="userTable" lay-filter="userTable"></table>
			</div>

	<script src="js/jquery.min.js"></script>
	<script src="layui/layui.js" charset="utf-8"></script>
	<script src="js/personal/GameItemString.js"></script>
    <script  type="text/html" id="ContentType2">
        {{#  if(d.ContentType == 1){ }}
            <span>商城</span>
        {{#  } else if(d.ContentType == 2) { }}
            <span>月卡</span>
        {{#  } else if(d.ContentType == 3) { }}
            <span>首充礼包</span>
        {{#  } else if(d.ContentType == 4) { }}
            <span>每日充值</span>
        {{#  } else if(d.ContentType == 5) { }}
            <span>投资炮倍</span>
        {{#  } else if(d.ContentType == 6) { }}
            <span>出海保险</span>
        {{#  } else if(d.ContentType == 7) { }}
            <span>N天持续奖励</span>
        {{#  } else if(d.ContentType == 8) { }}
            <span>炮倍解锁</span>
        {{#  } }}
    </script>
    
    <script  type="text/html" id="OrderState2">
        {{#  if(d.OrderState == 1){ }}
            <span class="layui-badge">未完成</span>
        {{#  } else if(d.OrderState == 2) { }}
            <span class="layui-badge layui-bg-green">已完成</span>
        {{#  } }}
    </script>
    
    <script  type="text/html" id="OrderType">
        <span>{{ rechargeChannel(d.OrderType) }}</span>
    </script>
    
	<script>
	layui.use([ 'table', 'form', 'layer', 'laydate'], function() {
	     var layer = layui.layer
	     ,form = layui.form
	     ,laydate = layui.laydate
	     ,table = layui.table;
	     
	     layer.config({
			extend: 'MySkin/style.css'
		});
	     
	     table.render({
				elem : '#userTable',
				url : 'recharge/list',
				method : 'post',
				title : '订单记录表',
				totalRow : true,
				id:'allAttTable',
				request:{
					pageName:'PageIndex',
					limitName:'PageCount'
				},
				where:{
					UserId: $('#UserID').val(),
					StartTime: $('#StartTime').val(),
					EndTime: $('#EndTime').val(),
					State: $('#State').val(),
					ContentType: $('#ContentType').val(),
					OrderID:$('#OrderID').val()
				}
				,
				cols : [ [ 
					{field : 'UserId',title : 'ID'}, 
					{field : 'Nickname',title : '玩家昵称名'}, 
					{field : 'OrderNo',title : '订单编号'}, 
					{field : 'OrderType',title : '支付渠道',templet:'#OrderType'}, 
					{field : 'OrderAmount',title : '订单金额(元)',sort : true}, 
					{field : 'ContentType',title : '商品类型',templet:'#ContentType2'}, 
					{field : 'ContentId',title : '商品ID',sort : true,hide:true}, 
					{field : 'OrderState',title : '状态',sort : true,templet:'#OrderState2',event:'OrderState'}, 
					{field : 'OrderCreateTime',title : '订单创建时间',sort : true}
					] ],
				page : true,//分页
				response : {
					statusCode : 200
				//重新规定成功的状态码为 200，table 组件默认为 0
				},
				parseData : function(res) { //将原始数据解析成 table 组件所规定的数据
					return {
						"code" : res.status, //解析接口状态
						"msg" : res.message, //解析提示文本
						"count" : res.count, //解析数据长度
						"data" : res.data
					//解析数据列表
					};
				}
			});
	     
	     //监测
	     table.on('tool(userTable)',function(obj){
	    	 var data = obj.data,
	    	 layEvent = obj.event;
	    	 if(layEvent === 'OrderState') {
	    		 var OrderNo = data.OrderNo;
	    		 
	    		 layer.confirm('确定充值到账吗？', {
	    			  skin: 'layer-ext-yourskin',
	    			  btn: ['确定','取消'] //按钮
	    			}, function(){
	    				$.ajax({
	    				type : 'post',
	    				url : 'recharge/offlinefinishOrder',
	    				data:{OrderNo:OrderNo},
	    				async : true,
	    				success : function(resp) {
	    					if (resp == "success") {
	    						layer.msg("操作成功",{icon:1});
	    						setTimeout(function(){
	    							table.reload('allAttTable', {});
	    	    				},2000);
	    					} else {
	    						layer.msg(resp,{icon:2});
	    					}
	    				}
	    			});
	    		});
	    	 }
	    	 
	     });

	     
	//日期选择器
	laydate.render({
	    elem: '#StartTime'
	    ,type: 'datetime' 
	  });
	laydate.render({
		elem: '#EndTime'
		,type: 'datetime' 
	});
	
	
	
	//根据条件查询表格数据重新加载
	  var active = {
		    reload: function(){
		    //获取用户名
		      //执行重载
		      table.reload('allAttTable', {
		        page: {
		          curr: 1 //重新从第 1 页开始
		      }
		      //根据条件查询
		        ,where: {
		        	UserId: $('#UserID').val(),
					StartTime: $('#StartTime').val(),
					EndTime: $('#EndTime').val(),
					State: $('#State').val(),
					ContentType: $('#ContentType').val(),
					OrderID:$('#OrderID').val()
		        }
		      });
		    return false;
		   }
		};
	
	
	  //点击搜索按钮根据用户名称查询
	  $('#SelectOrder').on('click',
        function(){
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });
	  
	  setInterval(function(){
		  table.reload('allAttTable', {
		        page: {
		          curr: 1 //重新从第 1 页开始
		      }
		      //根据条件查询
		        ,where: {
		        	UserId: $('#UserID').val(),
					StartTime: $('#StartTime').val(),
					EndTime: $('#EndTime').val(),
					State: $('#State').val(),
					ContentType: $('#ContentType').val(),
					OrderID:$('#OrderID').val()
		        }
		      });
        },60000);
});
</script>
</body>
</html>